from django.db import models
from django.contrib.auth.models import User
from django.utils import timezone

from datetime import datetime
from decouple import config

from core.models import BaseModel

import requests

# Create your models here.


class Account(BaseModel):

    # 用户账号
    user            = models.ForeignKey(User, on_delete=models.SET_NULL, null = True, blank = True)

    avatar          = models.ImageField('用户头像', upload_to='avatar', null = True, blank = True)

    nickname        = models.CharField('用户昵称', max_length = 128, null = True, blank = True)

    wx_openid       = models.CharField('微信OPENID', unique=True, max_length = 128, null = True, blank = True)

    wx_uuid         = models.CharField('微信UUID', unique=True, max_length = 128, null = True, blank = True)
    
    phone           = models.CharField('手机号', unique=True, max_length = 128, null = True, blank = True)
    
    email           = models.CharField('电子邮箱', unique=True, max_length = 128, null = True, blank = True)

    def __str__(self):
        return '{}-{}'.format(self.pk, self.nickname)

    class Meta:
        verbose_name = "用户资料"
        verbose_name_plural = "用户资料"
